<?php $url = new Url(); ?>
<div class="left">
    <?php $this->widget("AdminKetquaTrongngay")?>
    <?php $this->widget("AdminKetquaXoso")?>
</div>
<div class="right-main">
    <div class="righ-cont">
        <div class="right">
            <div class="title_style">
                <span><b>Kết quả xổ số Miền Trung </b></span>
            </div>
            <p>Mở thưởng tại <?=$rowProvince["name"] ?>, <?=$row["ngay_quay"] ?></p>
            <?php
                $arr_date = explode("/",$row["ngay_quay"]);
                $date_format = $arr_date[2]."-".$arr_date[1]."-".$arr_date[0];
            ?>
            <div class="tablestyle clearfix">
                <input type="hidden" value="<?=$rowProvince["id"]?>" id="province_id"/>
                <table cellspacing="0" cellpadding="0" border="0" width="100%">
                    <tbody>   
                        <tr>
                            <td>
                                <div class="table clearfix">
                                    <table cellspacing="0" cellpadding="0" border="0" width="100%">
                                        <tbody>   

                                            <tr>
                                                <td width="12%" class="text-left"><strong class="s16">Giải đặc biệt</strong></td>
                                                <td width="80%" class="text-left">
                                                    <b class="clred">
                                                        <input type="text" id="giai_dacbiet" name="giai_dacbiet" value="<?=isset($row["giai_dacbiet"])?$row["giai_dacbiet"]:"" ?>" style="width: 120px;"/>
                                                    </b><span id="giaidb"></span>
                                                </td>
                                                <td width="20%" class="bg_yellow"><a href="javascript:void(0);" onclick="saveGiaidacbiet();" class="save"> Save</a></td>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><strong>Giải  nhất</strong></td>
                                                <td class="text-left">
                                                    <b class="clblue">
                                                        <input type="text" id="giai_nhat" name="giai_nhat" value="<?=isset($row["giai_nhat"])?$row["giai_nhat"]:"" ?>" style="width: 120px;"/>
                                                    </b><span id="giai1"></span>
                                                </td>
                                                <td width="20%" class="bg_yellow"><a href="javascript:void(0);" onclick="saveGiainhat();" class="save"> Save</a></td>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><strong>Giải  nhì</strong></td>
                                                <td class="text-left">
                                                    <b class="clblue">
                                                        <input type="text" id="giai_nhi" name="giai_nhi" value="<?=isset($row["giai_nhi"])?$row["giai_nhi"]:"" ?>" style="width: 70px;"/>

                                                    </b><span id="giai2"></span></td>
                                                <td width="20%" class="bg_yellow"><a href="javascript:void(0);" onclick="saveGiainhi();" class="save"> Save</a></td>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><strong>Giải  ba</strong></td>
                                                <td class="text-left">
                                                    <b class="clblue">
                                                        <input type="text" id="giai_ba_1" name="giai_ba_1" value="<?=isset($row["giai_ba_1"])?$row["giai_ba_1"]:"" ?>" style="width: 50px;"/>
                                                        -
                                                        <input type="text" id="giai_ba_2" name="giai_ba_2" value="<?=isset($row["giai_ba_2"])?$row["giai_ba_2"]:"" ?>" style="width: 50px;"/>

                                                    </b><span id="giai3"></span></td>
                                                <td width="20%" class="bg_yellow"><a href="javascript:void(0);" onclick="saveGiaiba();" class="save"> Save</a></td>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><strong>Giải  tư</strong></td>
                                                <td class="text-left">
                                                    <b class="clblue">
                                                        <input type="text" id="giai_tu_1" name="giai_tu_1" value="<?=isset($row["giai_tu_1"])?$row["giai_tu_1"]:"" ?>" style="width: 50px;"/>
                                                        -
                                                        <input type="text" id="giai_tu_2" name="giai_tu_2" value="<?=isset($row["giai_tu_2"])?$row["giai_tu_2"]:"" ?>" style="width: 50px;"/>
                                                        -
                                                        <input type="text" id="giai_tu_3" name="giai_tu_3" value="<?=isset($row["giai_tu_3"])?$row["giai_tu_3"]:"" ?>" style="width: 50px;"/>
                                                        -
                                                        <input type="text" id="giai_tu_4" name="giai_tu_4" value="<?=isset($row["giai_tu_4"])?$row["giai_tu_4"]:"" ?>" style="width: 50px;"/>
                                                        -
                                                        <input type="text" id="giai_tu_5" name="giai_tu_5" value="<?=isset($row["giai_tu_5"])?$row["giai_tu_5"]:"" ?>" style="width: 50px;"/>
                                                        -
                                                        <input type="text" id="giai_tu_6" name="giai_tu_6" value="<?=isset($row["giai_tu_6"])?$row["giai_tu_6"]:"" ?>" style="width: 50px;"/>
                                                        -
                                                        <input type="text" id="giai_tu_7" name="giai_tu_7" value="<?=isset($row["giai_tu_7"])?$row["giai_tu_7"]:"" ?>" style="width: 50px;"/>
                                                    </b><span id="giai4"></span>
                                                </td>
                                                <td width="20%" class="bg_yellow"><a href="javascript:void(0);" onclick="saveGiaitu();" class="save"> Save</a></td>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><strong>Giải  năm</strong></td>
                                                <td class="text-left">
                                                    <b class="clblue">
                                                        <input type="text" id="giai_nam" name="giai_nam" value="<?=isset($row["giai_nam"])?$row["giai_nam"]:"" ?>" style="width: 50px;"/>

                                                    </b><span id="giai5"></span>
                                                </td>
                                                <td width="20%" class="bg_yellow"><a href="javascript:void(0);" onclick="saveGiainam();" class="save"> Save</a></td>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><strong>Giải  sáu</strong></td>
                                                <td class="text-left">
                                                    <b class="clblue">
                                                        <input type="text" id="giai_sau_1" name="giai_sau_1" value="<?=isset($row["giai_sau_1"])?$row["giai_sau_1"]:"" ?>" style="width: 70px;"/>
                                                        -
                                                        <input type="text" id="giai_sau_2" name="giai_sau_2" value="<?=isset($row["giai_sau_2"])?$row["giai_sau_2"]:"" ?>" style="width: 70px;"/>
                                                        -
                                                        <input type="text" id="giai_sau_3" name="giai_sau_3" value="<?=isset($row["giai_sau_3"])?$row["giai_sau_3"]:"" ?>" style="width: 70px;"/>
                                                    </b><span id="giai6"></span>
                                                </td>
                                                <td width="20%" class="bg_yellow"><a href="javascript:void(0);" onclick="saveGiaisau();" class="save"> Save</a></td>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><strong>Giải  bảy</strong></td>
                                                <td class="text-left">
                                                    <b class="clblue">
                                                        <input type="text" id="giai_bay" name="giai_bay" value="<?=isset($row["giai_bay"])?$row["giai_bay"]:"" ?>" style="width: 50px;"/>

                                                    </b><span id="giai7"></span></td>
                                                <td width="20%" class="bg_yellow"><a href="javascript:void(0);" onclick="saveGiaibay();" class="save"> Save</a></td>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><strong>Giải  tám</strong></td>
                                                <td class="text-left">
                                                    <b class="clblue">
                                                        <input type="text" id="giai_tam" name="giai_tam" value="<?=isset($row["giai_tam"])?$row["giai_tam"]:"" ?>" style="width: 50px;"/>

                                                    </b><span id="giai8"></span></td>
                                                <td width="20%" class="bg_yellow"><a href="javascript:void(0);" onclick="saveGiaitam();" class="save"> Save</a></td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </td>
                            <td width="60"><a href="javascript:void(0)" onclick="location.reload();" class="next"></a></td>
                            <td>
                                <div class="table clearfix">
                                    <table cellspacing="0" cellpadding="0" border="0" width="100%">
                                        <tbody>   
                                            <tr>
                                                <td width="10%" class="text-left"><strong class="s16">Giải đặc biệt</strong></td>
                                                <td width="70%" class="text-left"><b class="clred" id="gdb"><?=isset($row["giai_dacbiet"])?$row["giai_dacbiet"]:"?" ?></b></td>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><strong>Giải  nhất</strong></td>
                                                <td class="text-left"><b class="clblue" id="g1"><?=isset($row["giai_nhat"])?$row["giai_nhat"]:"?" ?></b></td>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><strong>Giải  nhì</strong></td>
                                                <td class="text-left"><b class="clblue" id="g2">
                                                    <?=isset($row["giai_nhi"])?$row["giai_nhi"]:"?" ?></b>

                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><strong>Giải  ba</strong></td>
                                                <td class="text-left">
                                                    <b class="clblue" id="g31">
                                                    <?=isset($row["giai_ba_1"])?$row["giai_ba_1"]:"?" ?></b>
                                                    </b>
                                                    &nbsp;-&nbsp;
                                                    <b class="clblue" id="g32">
                                                        <?=isset($row["giai_ba_2"])?$row["giai_ba_2"]:"?" ?>
                                                    </b>

                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><strong>Giải  tư</strong></td>
                                                <td class="text-left">
                                                    <b class="clblue" id="g41">
                                                        <?=isset($row["giai_tu_1"])?$row["giai_tu_1"]:"?" ?>
                                                    </b>
                                                    &nbsp;-&nbsp;
                                                    <b class="clblue" id="g42">
                                                        <?=isset($row["giai_tu_2"])?$row["giai_tu_2"]:"?" ?>
                                                    </b>
                                                    &nbsp;-&nbsp;
                                                    <b class="clblue" id="g43">
                                                        <?=isset($row["giai_tu_3"])?$row["giai_tu_3"]:"?" ?>
                                                    </b>
                                                    &nbsp;-&nbsp;
                                                    <b class="clblue" id="g44">
                                                        <?=isset($row["giai_tu_4"])?$row["giai_tu_4"]:"?" ?>
                                                    </b>
                                                    &nbsp;-&nbsp;
                                                    <b class="clblue" id="g45">
                                                        <?=isset($row["giai_tu_5"])?$row["giai_tu_5"]:"?" ?>
                                                    </b>
                                                    &nbsp;-&nbsp;
                                                    <b class="clblue" id="g46">
                                                        <?=isset($row["giai_tu_6"])?$row["giai_tu_6"]:"?" ?>
                                                    </b>
                                                    &nbsp;-&nbsp;
                                                    <b class="clblue" id="g47">
                                                        <?=isset($row["giai_tu_7"])?$row["giai_tu_7"]:"?" ?>
                                                    </b>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><strong>Giải  năm</strong></td>
                                                <td class="text-left">
                                                    <b class="clblue" id="g5">
                                                        <?=isset($row["giai_nam"])?$row["giai_nam"]:"?" ?>
                                                    </b>

                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><strong>Giải  sáu</strong></td>
                                                <td class="text-left">
                                                    <b class="clblue" id="g61">
                                                        <?=isset($row["giai_sau_1"])?$row["giai_sau_1"]:"?" ?>
                                                    </b>
                                                    &nbsp;-&nbsp;
                                                    <b class="clblue" id="g62">
                                                        <?=isset($row["giai_sau_2"])?$row["giai_sau_2"]:"?" ?>
                                                    </b>
                                                    &nbsp;-&nbsp;
                                                    <b class="clblue" id="g63">
                                                        <?=isset($row["giai_sau_3"])?$row["giai_sau_3"]:"?" ?>
                                                    </b></td>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><strong>Giải  bảy</strong></td>
                                                <td class="text-left">
                                                    <b class="clblue" id="g7">
                                                        <?=isset($row["giai_bay"])?$row["giai_bay"]:"?" ?>
                                                    </b>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><strong>Giải  tám</strong></td>
                                                <td class="text-left">
                                                    <b class="clblue" id="g8">
                                                        <?=isset($row["giai_tam"])?$row["giai_tam"]:"?" ?>
                                                    </b>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table> 
                                </div>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var ngay_quay = '<?=$row["ngay_quay"] ?>';
    var count_province = 1;
    function saveGiaidacbiet(){
        var strUrl = '<?=$url->createUrl("trongngay/saveGiaiDacbietMientrung") ?>';
        var giai_dacbiet = ""; 
        var province_id = "";

        giai_dacbiet += $("#giai_dacbiet").val()+";";
        province_id +=$("#province_id").val()+";";

        $.ajax({
            type: "POST",
            url: strUrl,
            data: {
                giai_dacbiet:giai_dacbiet,
                province_id:province_id,
                ngay_quay:ngay_quay
            },
            success: function(msg){
                $("#giaidb").removeClass("loading");
                if(msg==1){                   
                    $("#giaidb").html("OK");
                    $("#gdb").html($("#giai_dacbiet").val());
                }else{
                    $("#giaidb").html("Loi");
                }       
            },
            beforeSend:function(){
                $("#giaidb").html("");
                $("#giaidb").addClass("loading");
            }
        });    
    }
    function saveGiainhat(){
        var strUrl = '<?=$url->createUrl("trongngay/saveGiaiNhatMientrung") ?>';
        var giai_nhat = ""; 
        var province_id = "";
        giai_nhat += $("#giai_nhat").val()+";";
        province_id +=$("#province_id").val()+";";

        $.ajax({
            type: "POST",
            url: strUrl,
            data: {
                giai_nhat:giai_nhat,
                province_id:province_id,
                ngay_quay:ngay_quay
            },
            success: function(msg){
                $("#giai1").removeClass("loading");
                if(msg==1){                   
                    $("#giai1").html("OK");
                    $("#g1").html($("#giai_nhat").val());

                }else{
                    $("#giai1").html("Loi");
                }       
            },
            beforeSend:function(){
                $("#giai1").html("");
                $("#giai1").addClass("loading");
            }
        });    
    }
    function saveGiainhi(){
        var strUrl = '<?=$url->createUrl("trongngay/saveGiaiNhiMientrung") ?>';
        var giai_nhi = ""; 
        var province_id = "";

        giai_nhi += $("#giai_nhi").val()+";";
        province_id +=$("#province_id").val()+";";

        $.ajax({
            type: "POST",
            url: strUrl,
            data: {
                giai_nhi:giai_nhi,
                province_id:province_id,
                ngay_quay:ngay_quay
            },
            success: function(msg){
                $("#giai2").removeClass("loading");
                if(msg==1){                   
                    $("#giai2").html("OK");

                    $("#g2").html($("#giai_nhi").val());

                }else{
                    $("#giai2").html("Loi");
                }       
            },
            beforeSend:function(){
                $("#giai2").html("");
                $("#giai2").addClass("loading");
            }
        });    
    }
    function saveGiaiba(){
        var strUrl = '<?=$url->createUrl("trongngay/saveGiaiBaMientrung") ?>';
        var giai_ba_1 = "";
        var giai_ba_2 = "";  
        var province_id = "";

        giai_ba_1 += $("#giai_ba_1").val()+";";
        giai_ba_2 += $("#giai_ba_2").val()+";";
        province_id +=$("#province_id").val()+";";
        $.ajax({
            type: "POST",
            url: strUrl,
            data: {
                giai_ba_1:giai_ba_1,
                giai_ba_2:giai_ba_2,
                province_id:province_id,
                ngay_quay:ngay_quay
            },
            success: function(msg){
                $("#giai3").removeClass("loading");
                if(msg==1){                   
                    $("#giai3").html("OK");

                    $("#g31").html($("#giai_ba_1").val());
                    $("#g32").html($("#giai_ba_2").val());

                }else{
                    $("#giai3").html("Loi");
                }       
            },
            beforeSend:function(){
                $("#giai3").html("");
                $("#giai3").addClass("loading");
            }
        });    
    }
    function saveGiaitu(){
        var strUrl = '<?=$url->createUrl("trongngay/saveGiaiTuMientrung") ?>';
        var giai_tu_1 = "";
        var giai_tu_2 = ""; 
        var giai_tu_3 = "";
        var giai_tu_4 = "";
        var giai_tu_5 = ""; 
        var giai_tu_6 = "";
        var giai_tu_7 = ""; 
        var province_id = "";

        giai_tu_1 += $("#giai_tu_1").val()+";";
        giai_tu_2 += $("#giai_tu_2").val()+";";
        giai_tu_3 += $("#giai_tu_3").val()+";";
        giai_tu_4 += $("#giai_tu_4").val()+";";
        giai_tu_5 += $("#giai_tu_5").val()+";";
        giai_tu_6 += $("#giai_tu_6").val()+";";
        giai_tu_7 += $("#giai_tu_7").val()+";";
        province_id +=$("#province_id").val()+";";

        $.ajax({
            type: "POST",
            url: strUrl,
            data: {
                giai_tu_1:giai_tu_1,
                giai_tu_2:giai_tu_2,
                giai_tu_3:giai_tu_3,
                giai_tu_4:giai_tu_4,
                giai_tu_5:giai_tu_5,
                giai_tu_6:giai_tu_6,
                giai_tu_7:giai_tu_7,
                province_id:province_id,
                ngay_quay:ngay_quay
            },
            success: function(msg){

                $("#giai4").removeClass("loading");
                if(msg==1){                   
                    $("#giai4").html("OK");

                    $("#g41").html($("#giai_tu_1").val());
                    $("#g42").html($("#giai_tu_2").val());
                    $("#g43").html($("#giai_tu_3").val());
                    $("#g44").html($("#giai_tu_4").val());
                    $("#g45").html($("#giai_tu_5").val());
                    $("#g46").html($("#giai_tu_6").val());
                    $("#g47").html($("#giai_tu_7").val());

                }else{
                    $("#giai4").html("Loi");
                }       
            },
            beforeSend:function(){
                $("#giai4").html("");
                $("#giai4").addClass("loading");
            }
        });    
    }
    function saveGiainam(){
        var strUrl = '<?=$url->createUrl("trongngay/saveGiaiNamMientrung") ?>';
        var giai_nam = "";
        var province_id = "";

        giai_nam += $("#giai_nam").val()+";";
        province_id +=$("#province_id").val()+";";

        $.ajax({
            type: "POST",
            url: strUrl,
            data: {
                giai_nam:giai_nam,
                province_id:province_id,
                ngay_quay:ngay_quay
            },
            success: function(msg){
                //alert(msg);
                $("#giai5").removeClass("loading");
                if(msg==1){                   
                    $("#giai5").html("OK");

                    $("#g5").html($("#giai_nam").val());

                }else{
                    $("#giai5").html("Loi");
                }       
            },
            beforeSend:function(){
                $("#giai5").html("");
                $("#giai5").addClass("loading");
            }
        });    
    }
    function saveGiaisau(){
        var strUrl = '<?=$url->createUrl("trongngay/saveGiaiSauMientrung") ?>';
        var giai_sau_1 = "";
        var giai_sau_2 = ""; 
        var giai_sau_3 = ""; 
        var province_id = "";

        giai_sau_1 += $("#giai_sau_1").val()+";";
        giai_sau_2 += $("#giai_sau_2").val()+";";
        giai_sau_3 += $("#giai_sau_3").val()+";";
        province_id +=$("#province_id").val()+";";

        $.ajax({
            type: "POST",
            url: strUrl,
            data: {
                giai_sau_1:giai_sau_1,
                giai_sau_2:giai_sau_2,
                giai_sau_3:giai_sau_3,
                province_id:province_id,
                ngay_quay:ngay_quay
            },
            success: function(msg){
                $("#giai6").removeClass("loading");
                if(msg==1){                   
                    $("#giai6").html("OK");

                    $("#g61").html($("#giai_sau_1").val());
                    $("#g62").html($("#giai_sau_2").val());
                    $("#g63").html($("#giai_sau_3").val());

                }else{
                    $("#giai6").html("Loi");
                }       
            },
            beforeSend:function(){
                $("#giai6").html("");
                $("#giai6").addClass("loading");
            }
        });    
    }
    function saveGiaibay(){  
        var strUrl = '<?=$url->createUrl("trongngay/saveGiaiBayMientrung") ?>';
        var giai_bay = "";
        var province_id = "";

        giai_bay += $("#giai_bay").val()+";";
        province_id +=$("#province_id").val()+";";

        $.ajax({
            type: "POST",
            url: strUrl,
            data: {
                giai_bay:giai_bay,
                province_id:province_id,
                ngay_quay:ngay_quay
            },
            success: function(msg){
                $("#giai7").removeClass("loading");
                if(msg==1){                   
                    $("#giai7").html("OK");

                    $("#g7").html($("#giai_bay").val());

                }else{
                    $("#giai7").html("Loi");
                }       
            },
            beforeSend:function(){
                $("#giai7").html("");
                $("#giai7").addClass("loading");
            }
        });    

    }

    function saveGiaitam(){
        var strUrl = '<?=$url->createUrl("trongngay/saveGiaiTamMientrung") ?>';
        var giai_tam = "";
        var province_id = "";

        giai_tam += $("#giai_tam").val()+";";
        province_id +=$("#province_id").val()+";";


        $.ajax({
            type: "POST",
            url: strUrl,
            data: {
                giai_tam:giai_tam,
                province_id:province_id,
                ngay_quay:ngay_quay
            },
            success: function(msg){
                alert(msg);
                $("#giai8").removeClass("loading");
                if(msg==1){                   
                    $("#giai8").html("OK");

                    $("#g8").html($("#giai_tam").val());

                }else{
                    $("#giai8").html("Loi");
                }       
            },
            beforeSend:function(){
                $("#giai8").html("");
                $("#giai8").addClass("loading");
            }
        });    

    }
</script>
